package componentes;
import java.awt.Color;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

/**
 * @author Reynald0
 */
public class CompBoton extends JButton
{
   public CompBoton(JPanel pPanel)
   {
      this(pPanel, "Nuevo Boton");
   }
   
   public CompBoton(JPanel pPanel,String pEtiqueta)
   {
      this(pPanel, pEtiqueta, null);
   }
   
   public CompBoton(JPanel pPanel,String pEtiqueta, ActionListener pAccion)
   {
      this(pPanel, pEtiqueta, pAccion, null);
   }
   
   public CompBoton(JPanel pPanel,String pEtiqueta,ActionListener pAccion, Color pColor)
   {
      this(pPanel, pEtiqueta, pAccion, pColor, null);
   }
   
   public CompBoton(JPanel pPanel,String pEtiqueta,ActionListener pAccion, Color pColor,Color pLetra)
   {
      this(pPanel,pEtiqueta,pAccion, pColor, pLetra,"");
   }
   
   public CompBoton(JPanel pPanel,String pEtiqueta,ActionListener pAccion,Color pColor,Color pLetra,String pImagen)
   {
      this.setIcon(new ImageIcon(pImagen)); 
      if(pEtiqueta == null) 
         pEtiqueta = "Nuevo Boton";
     
      this.setFocusable(false);
      this.setText(pEtiqueta);
      this.setAlignmentX(CENTER_ALIGNMENT);
      this.addActionListener(pAccion);
      
      if (pColor != null)
         this.setBackground(pColor);
      if (pLetra != null)
         this.setForeground(pLetra);
      if(pPanel!=null)
         pPanel.add(this);
      if(pImagen != null || pImagen != "")
         this.setIcon(new ImageIcon(pImagen));
   }
}
